#ifndef HANDLEFACTORY_HANDLEFACTORYOBJECTCREATORIMPL_H
#define HANDLEFACTORY_HANDLEFACTORYOBJECTCREATORIMPL_H

///////////////////////////////////////////////////////////////////////////////
//
// HandleFactoryObjectCreatorImpl.h
//
///////////////////////////////////////////////////////////////////////////////
//
// Author:            Jan Maes
// Created:           Sunday, June 15, 2008
// Responsibilities:  Implementation of handle creation
// Usage:             Only to be called from HandleFactory
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// namespace HandleFactory
///////////////////////////////////////////////////////////////////////////////

namespace HandleFactory
  {

  ///////////////////////////////////////////////////////////////////////////////
  // class HandleFactoryObjectCreatorImpl
  ///////////////////////////////////////////////////////////////////////////////

  template <class TObject, class THandle, bool TPublicDestructor>
  class HandleFactoryObjectCreatorImpl
    {    
    private:

      template <class TObject, class THandle, bool TPublicDestructor>
      friend class HandleFactory;

      template <class TDeleter>
      static THandle Create(TObject* ip_object)
        {
        return THandle(ip_object);
        }

      template <class TDeleter>
      static const THandle CreateConst(TObject* ip_object)
        {
        return THandle(ip_object);
        }

    };

  ///////////////////////////////////////////////////////////////////////////////
  // Partial template specialization
  ///////////////////////////////////////////////////////////////////////////////

  template <class TObject, class THandle>
  class HandleFactoryObjectCreatorImpl<TObject, THandle, false>
    {    
    private:

      template <class TObject, class THandle, bool TPublicDestructor>
      friend class HandleFactory;

      template <class TDeleter>
      static THandle Create(TObject* ip_object)
        {
        return THandle(ip_object, TDeleter());
        }

      template <class TDeleter>
      static const THandle CreateConst(TObject* ip_object)
        {
        return THandle(ip_object, TDeleter());
        }

    };

  ///////////////////////////////////////////////////////////////////////////////

  } // namespace HandleFactory



#endif